import numpy as np

X_train = np.loadtxt('X_train.txt', delimiter=',')
n = X_train.shape[1]#featute
m = X_train.shape[0]
labels = 2
mu = np.random.rand(n,labels)
c = np.zeros((m,1))
for i in range(m):
    d_m = 10000
    for j in range(labels):
        d = np.dot(X_train[i] - mu[:,j].T, X_train[i].T - mu[:,j])
        if d < d_m:
            c[i] = j;

for j in range(labels):
    m_sum = 0
    for i in range(m):
        if c[i,1] == j :
            m_sum += 1
            mu[:,j] = mu[:,j] + X_train[i].T
    mu[:,j] = mu[:,j] / m_sum



